/**
 * Created by Willian on 2015/9/17.
 *
 */
function HuxingSum(id,title,showMore){
    this.id = id;
    this.title = title;
    this.seriesOptions = [];
    this.xAxiscategories = [];
    this.showMore = showMore;

    this.create = function(){
        var _self = this;
        Highcharts.setOptions({ global: { useUTC: false } });

        $('#'+_self.id).highcharts({
            title : {
                text :_self.title+" 户型统计"
            },
            chart : {
                type: 'Areaspline'
            },
            yAxis: {
                floor: 0
            },
            xAxis: {
                categories: _self.xAxiscategories
            },
            legend: {
                enabled: false
            },
            credits : {
                enabled : false
            },
            exporting : {
                enabled : false
            },
            scrollbar : {
                liveRedraw: false
            },
            navigator:{
                adaptToUpdatedData : false
            },
            series: _self.seriesOptions
        });
    }
}

HuxingSum.prototype.show = function(xiaoqu){
    var _self = this;
    var txt = encodeURI(xiaoqu,"utf-8");
    var colors=['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#FF00FF', '#F42572', '#902F0F','#2F32FF', '#6AF9C4','#FD33D5','#BFFB23','#00FF00'];
    $.getJSON(ctx+'/sumHxByXiaoqu?keyword='+txt,function (data){
        var distData = new Array(data.length);

        for(var i =0;i<data.length;i++){
            distData[i]=new Array(data[i].district,data[i].count);
            _self.xAxiscategories.push(data[i].district);
        }

        _self.seriesOptions = [
            {
                name: '数量',
                type : 'spline',
                data: distData
            }
        ];
        //
        _self.create();
    });
}